#include <iostream>
#include <iomanip>
using namespace std;
class Date;

class Time
{
private:
    int hour;
    int minute;
    int second;

public:
    Time(int hour1, int minute1, int second1)
    {
        hour = hour1;
        minute = minute1;
        second = second1;
    }
    friend void Display(Date &, Time &);
};

class Date
{
private:
    int year;
    int month;
    int day;

public:
    Date(int year1, int month1, int day1)
    {
        year = year1;
        month = month1;
        day = day1;
    }
    friend void Display(Date &, Time &);
};

void Display(Date &Date1, Time &Time1) //定义的全局函数同时作为两个类的友元函数
{
    cout << Date1.year << "-" << setfill('0') << setw(2) << Date1.month << "-" << setfill('0') << setw(2) << Date1.day << " " << setfill('0') << setw(2) << Time1.hour << ":" << setfill('0') << setw(2) << Time1.minute << ":" << setfill('0') << setw(2) << Time1.second << endl;
}

int main()
{
    int i, t;
    cin >> t;
    for (i = 0; i < t; i++)
    {
        int year1, month1, day1, hour1, minute1, second1;
        cin >> year1 >> month1 >> day1 >> hour1 >> minute1 >> second1;
        Date Date1(year1, month1, day1);
        Time Time1(hour1, minute1, second1);
        Display(Date1, Time1);
    }
    return 0;
}
